<?php

namespace app\api\controller;

use app\api\extend\Common;
use think\facade\Db;

class HomeChartmessages extends Common
{
    
    public function list() {
        $pageNum = $this->params['pageNum'] ?? 1;
        $pageSize = $this->params['pageSize'] ?? 10;
     
        $userId = $this->request->auth['userId'];
        $friendId = $this->params['friend_id'];
     
        $res = Db::name('home_chartmessages')
            ->whereIn('user_id', [$userId, $friendId])
            ->whereIn('friend_id', [$userId, $friendId])
            ->order('timestamp', 'desc')
            ->page($pageNum, $pageSize)
            ->select()->toArray();

        $res = array_reverse($res);
     
        return $this->return_msg(200, '获取成功', $res);
    }

}